package com.example.lx6_1.area

import androidx.paging.PagingSource
import androidx.paging.PagingState
import com.example.base.entity.AreaEntityItem
import com.example.base.net.ApiService

class AreaSource(val apiService: ApiService) : PagingSource<Int, AreaEntityItem>() {
    override fun getRefreshKey(state: PagingState<Int, AreaEntityItem>): Int? {
        return null
    }

    override suspend fun load(params: LoadParams<Int>): LoadResult<Int, AreaEntityItem> {
        try {
            val area = apiService.getArea(1)
            return LoadResult.Page(area.data,null,null)
        }catch (e:Exception){
            return LoadResult.Error(e)
        }
    }

}